﻿@model zichan.Models.OldPutawayModel
@{
    ViewBag.Title = "上架已有服务器";
}

@section Pagetitle{
    @AdminCommon.PageTitle("机柜管理", "上架")
}
@section header{
    <link rel="stylesheet" type="text/css" href="/assets/global/plugins/select2/select2.css" />
    <link href="/assets/global/css/plugins.css" rel="stylesheet" type="text/css" />
}

@using (Html.BeginForm("OldPutServer", "Cabinet", FormMethod.Post, new { @class = "form-horizontal",@id="OldPutServer" }))
{
    <div class="form-body">
        @Html.AntiForgeryToken()
        <div class="form-group ">
            <label class="col-md-3 control-label xh">机房:</label>
            <div class="col-md-9">
                @Html.DropDownList("MachineRoomId", (SelectList)ViewBag.machineRoomIds, "请选择机房", new { @class = "form-control input-large" })
                <span class="help-block">
                    @Html.ValidationMessageFor(o => o.MachineRoomId)
                </span>
            </div>
        </div>

        <div class="form-group " id="cabinetDrowpList">
            <label class="col-md-3 control-label xh">机柜:</label>
            <div class="col-md-9">
                @Html.DropDownList("CabinetId", (SelectList)ViewBag.cabinetIds, "请选择机柜", new { @class = "form-control input-large" })
                <span class="help-block">
                    @Html.ValidationMessageFor(o => o.CabinetId)
                </span>
            </div>
        </div>
        <div id="u_NO">
            <div class="form-group ">
                <label class="col-md-3 control-label xh">标准机架数:</label>
                <div class="col-md-9">
                    <span style="color:red;">请选择机房/机柜</span>
                </div>
            </div>
            <div class="form-group ">
                <label class="col-md-3 control-label xh">剩余机架数:</label>
                <div class="col-md-9">
                    <span style="color:red;">请选择机房/机柜</span>
                </div>
            </div>
        </div>
        <div class="form-group ">
            <label class="col-md-3 control-label xh">所属公司:</label>
            <div class="col-md-9">
                @Html.DropDownList("CompanyId", (SelectList)ViewBag.companyIds, "请选择公司", new { @class = "form-control input-large" })
                <span class="help-block">
                    @Html.ValidationMessageFor(o => o.CompanyId)
                </span>
            </div>
        </div>
        <div class="form-group ">
            <label class="col-md-3 control-label xh">用途:</label>
            <div class="col-md-9">
                @Html.DropDownList("PurposeId", (SelectList)ViewBag.cabinetClassIds, "请选择用途", new { @class = "form-control input-large" })
                <span class="help-block">
                    @Html.ValidationMessageFor(o => o.PurposeId)
                </span>
            </div>
        </div>
        <div class="form-group " id="property" style="display:none">
            <label class="col-md-3 control-label xh">资产标识:</label>
            <div class="col-md-9">
                <select name="Property" id="Property" class="form-control select2 input-large">
                    @foreach (var s in ViewBag.Propertys)
                    {
                        <option value="@s.Value">@s.Text</option>
                    }
                </select>
            </div>
        </div>
        <div class="form-group " id="Tproperty" style="display:none">
            <label class="col-md-3 control-label xh">资产标识:</label>
            <div class="col-md-9">
                <select name="TProperty" id="TProperty" class="form-control select2 input-large">
                    @foreach (var s in ViewBag.TPropertys)
                    {
                        <option value="@s.Value">@s.Text</option>
                    }
                </select>
            </div>
        </div>
        <div class="form-group " id="Server_Code">
            <label class="col-md-3 control-label xh">服务器名称:</label>
            <div class="col-md-9">
                @Html.TextBoxFor(o => o.Name, new { @class = "form-control input-large" })
                <span class="help-block">
                    @Html.ValidationMessageFor(o => o.Name)
                </span>
            </div>
        </div>
        <div class="form-group ">
            <label class="col-md-3 control-label xh">序列号:</label>
            <div class="col-md-9">
                @Html.TextBoxFor(o => o.SerialNumber, new { @class = "form-control input-large" })
                <span class="help-block">
                    @Html.ValidationMessageFor(o => o.SerialNumber)
                </span>
            </div>
        </div>
        <div class="form-group ">
            <label class="col-md-3 control-label xh">占位:</label>
            <div class="col-md-9">
              @Html.TextBoxFor(o => o.UseNumber, new { @class = "form-control input-large" })
                <span class="help-block">
                    @Html.ValidationMessageFor(o => o.UseNumber)
                </span>
                <span id="U_error">

                </span>
            </div>
        </div>
      
        <div class="form-group ">
            <label class="col-md-3 control-label xh">使用者:</label>
            <div class="col-md-9">
                @Html.DropDownList("UserId", (SelectList)ViewBag.userIds, "请选择使用者", new { @class = "form-control select2 input-large" })
                <span class="help-block">
                    @Html.ValidationMessageFor(o => o.UserId)
                </span>
            </div>
        </div>
        <div class="form-group " id="mainIP">
            <label class="col-md-3 control-label xh">服务器主IP:</label>
            <div class="col-md-9">
                @Html.DropDownList("IPId", (SelectList)ViewBag.ipIds, "请选择IP", new { @class = "form-control input-large" })
                <span class="help-block">
                    @Html.ValidationMessageFor(o => o.IPId)
                </span>
            </div>
        </div>
        <div class="form-group " id="Sub_IP">
            <label class="col-md-3 control-label">服务器副IP:</label>
            <div class="col-md-9">
                @*@Html.DropDownList("SubIPId", (SelectList)ViewBag.subIpIds, "请选择副IP", new { @class = "form-control input-large" })*@
                <select name="SubIPId" id="SubIPId" placeholder="可多选" class="form-control input-large select2" multiple>
                    @foreach (var s in ViewBag.subIpIds)
                    {
                        <option value="@s.Value" @(Model != null && Model.SubIPIds.Contains(s.Value) ? "selected" : "")>@s.Text</option>
                    }
                </select>
            </div>
        </div>


        <div class="form-group">
            <label class="col-md-3 control-label">内网IP:</label>
            <div class="col-md-9">
                @Html.TextBoxFor(o => o.IntranetIP, new { @class = "form-control input-large" })

            </div>
        </div>
        <div class="form-group">
            <label class="col-md-3 control-label">IP反解:</label>
            <div class="col-md-9">
                @*<input type="radio" class="D_ExceptId" id="D_ExceptId1" name="D_ExceptId" checked="checked" />无，请设计组安排<br />*@
                @Html.RadioButtonFor(o => o.IsInverse, true, new { @checked = true })<span>是</span>
                @Html.RadioButtonFor(o => o.IsInverse, false)<span>否</span>
            </div>
        </div>
        <div class="form-group">
            <label class="col-md-3 control-label">上架备注:</label>
            <div class="col-md-9">
                @Html.TextAreaFor(o => o.Remark, new { @class = "form-control input-large", @placeholder = "可填写服务器实际所在机柜机架编号（机房制定的编号）" })

            </div>
        </div>

        <div class="form-actions">
            <div class="row">
                <div class="col-md-offset-3 col-md-9">
                    <button type="submit" class="btn green">提交</button>
                    <a href="/Cabinet/Index" class="btn default">返回</a>
                </div>
            </div>
        </div>
    </div>
}


@section footer{
    @Scripts.Render("~/bundles/jqueryval")
    <script type="text/javascript" src="/assets/global/plugins/select2/select2.min.js"></script>
    <script src="~/assets/global/plugins/select2/select2_locale_zh-CN.js"></script>
    <script src="~/Scripts/AssetJs.js"></script>
    <script>
    $(function () {
        var re = /^[0-9]+.?[0-9]*$/;
       
        $("#CabinetId").trigger('change');

        if (re.test($("#MachineRoomId").val())) {
            var id = $("#MachineRoomId").val();
            $("#mainIP").load("/Common/part_Ip?machineRoomId=" + id);
        }
        if (re.test($("#serverPurposeId").val())) {
            var id = $("#serverPurposeId").val();
            $("#subPurpose").load("/Common/part_serverSubPurpose?purposeId=" + id);
        }
        if (re.test($("#PurposeId").val())) {
            var id = $("#PurposeId").val();
            if (id == 1) {
                $("#property").css({ "display": "block" });
            }
            else if (id == 2) {
                $("#Tproperty").css({ "display": "block" });
            }

        }
        $("#MachineRoomId").on("change", function () {
            var id = $(this).val();
            $("#cabinetDrowpList").load("/Common/part_cabinet?machineRoomId=" + id);
            $("#mainIP").load("/Common/part_Ip?machineRoomId=" + id);
        });
        $("#serverPurposeId").on("change", function () {
            var id = $("#serverPurposeId").val();
            $("#subPurpose").load("/Common/part_serverSubPurpose?purposeId=" + id);
        });
        $('#SubIPId').select2({
            placeholder: "",
            allowClear: false
        });
        $('#UserId').select2({
            placeholder: "",
            allowClear: false

        });
    })
    </script>
}

